﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sharp.Migrations;

namespace Budgeter.Migrations
{

    class _002_Populate_Interval : DataMigration
    {

        public override void Up()
        {
            var DATA = new[]
            {
                new { Abbreviation = "d",  Name = "day",       YearEquivalent = 1f / 365 },
                new { Abbreviation = "w",  Name = "week",      YearEquivalent = 7f / 365 },
                new { Abbreviation = "2w", Name = "fortnight", YearEquivalent = 14f / 365 },
                new { Abbreviation = "4w", Name = "4 weeks",   YearEquivalent = 28f / 365 },
                new { Abbreviation = "m",  Name = "month",     YearEquivalent = 1f / 12 },
                new { Abbreviation = "2m", Name = "2 month",   YearEquivalent = 2f / 12 },
                new { Abbreviation = "3m", Name = "3 month",   YearEquivalent = 1f / 4 },
                new { Abbreviation = "6m", Name = "6 month",   YearEquivalent = 1f / 2 },
                new { Abbreviation = "y",  Name = "year",      YearEquivalent = 1f },
            };

            foreach (var i in DATA)
            {
                Insert.Into("Interval")
                    .Columns("Abbreviation", "Name", "YearEquivalent")
                    .Values(i.Abbreviation, i.Name, i.YearEquivalent);
            }
        }

        public override void Down()
        {
            Delete.From("Interval").AllRows();
        }

    }

}
